//
//  DetailRowGroup.swift
//  KoiAccounting
//
//  Created by 纪洪文 on 22.03.25.
//

import Foundation
struct AccountingDetailRowGroup :Identifiable{
    // 给 ui list 用的
    var id:Int
    // 按日期分组的收入和支出
    var date:String
    var dateOriginal:String
    var expenseAmount:Double
    var incomeAmount:Double
    // 分组中的详细数据集合
    var groupData:Array<AccountingDetailCombine>
    
    func getDateText() -> String {
        return date
    }
    
    func getExpenseAndIncome() -> String {
        let formatter = NumberFormatter()
        formatter.minimumFractionDigits = 0
        formatter.maximumFractionDigits = 2
        var expenseText = ""
        var incomeText = ""
        if (expenseAmount != 0) {
            expenseText = "支出 " + formatter.string(from: NSNumber(value: expenseAmount)).orEmpty
        }
        if (incomeAmount != 0) {
            incomeText = "  收入 " + formatter.string(from: NSNumber(value: incomeAmount)).orEmpty
        }
        return expenseText + incomeText
    }
}
